DATABASE=postgis_topo_regress

PSQL=psql
PERL=@PERL@

# MingW hack: rather than use PGSQL_BINDIR directly, we change to the directory and
# then use "pwd" to return the path. This ensures that the returned path is in MSYS
# format, otherwise colons in drive letters will break PATH.
PGSQL_BINDIR=$(shell cd "@PGSQL_BINDIR@" && pwd)

#
# Put path from pg_config into front of search path
#
PATH := $(PGSQL_BINDIR):$(PATH)
export PATH

all:
	@echo "Use 'make check' to run all tests"

# TODO: make edit_topology.sql into a proper test
edit:
	$(PSQL) -X -f edit_topology.sql $(DATABASE)


topo_predicates.sql: predicates.sql.in
	cpp -P -traditional-cpp predicates.sql.in | sed -e 's:@COLUMN@:feature:g;s:@SCHEMA@:public.:g' > topo_predicates.sql

load_topology.sql: load_topology.sql.in
	cpp -P -traditional-cpp load_topology.sql.in | sed -e 's:@SRID@:-1:g' > load_topology.sql

load_topology-4326.sql: load_topology.sql.in
	cpp -P -traditional-cpp load_topology.sql.in | sed -e 's:@SRID@:4326:g' > load_topology-4326.sql

clean distclean:
	rm -f topo_predicates.sql load_topology.sql load_topology-4326.sql

check: check-regress
check-regress: check-regress-deps

check-regress-deps: topo_predicates.sql load_topology.sql load_topology-4326.sql

topsrcdir = $(realpath ../../)
srcdir = $(realpath .)

include tests.mk
include ../../regress/runtest.mk
